package cn.yeziji.forum.controller;

import cn.yeziji.forum.common.ForumResult;
import cn.yeziji.forum.service.UploadFileService;
import cn.yeziji.forum.utils.ForumResultUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 上传文件接口
 *
 * @author gzkemays
 * @since 2022/3/28 23:29
 */
@RestController
@RequestMapping("/uploadFile")
public class ForumUploadFileController {
  @Resource UploadFileService uploadFileService;

  @PostMapping("/upload")
  public ForumResult upload(MultipartFile[] files) {
    return ForumResultUtils.ok(uploadFileService.uploadChatRoomFile(files));
  }

  @PostMapping("/dupload")
  public ForumResult detailUpload(MultipartFile[] files) {
    return ForumResultUtils.ok(uploadFileService.uploadDetailFile(files));
  }
}
